home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_exmh.idb / usr / freeware / lib / exmh-2.5 / flag.tcl.z / flag.tcl
Text File  |  2002-07-08  |  4KB  |  122 lines

  1. # flag.tcl
  2. #
  3. # Manage the iconic flag feedback.  The flag module understands three states,
  4. # but the icon only shows two states:
  5. #
  6. # State 0 - no unseen messages.
  7. # State 1 - newly arrived unseen messages.
  8. # State 2 - messages viewed while in State 1, but not necessarily all unseen
  9. #    messages viewed yet.
  10. #
  11. # The mailbox flag goes up on the transition to State 1 (from either State 0
  12. # or State 2), and the flag goes down on the transition to State 2.  So,
  13. # it is possible to have the flag down and still have unseen messages.  The
  14. # idea is that the flag means new mail has arrived since you last looked
  15. # at *something*.
  16. #
  17. # Copyright (c) 1993 Xerox Corporation.
  18. # Use and copying of this software and preparation of derivative works based
  19. # upon this software are permitted. Any distribution of this software or
  20. # derivative works must comply with all applicable United States export
  21. # control laws. This software is made available AS IS, and Xerox Corporation
  22. # makes no warranty about the software, its performance or its conformity to
  23. # any specification.
  24.  
  25. proc Flag_Init {} {
  26.     global flag exmh
  27.     set flag(state) init
  28.     
  29.     # Note - if you change the icon, there is some code in ExmhArgv
  30.     # that positions icons that can depend on the iconsize.
  31.     Preferences_Resource flag(iconup) iconUpBitmap flagup.bitmap
  32.     Preferences_Resource flag(icondown) iconDownBitmap flagdown.bitmap
  33.     Preferences_Resource flag(iconspool) iconSpoolBitmap flagspool.bitmap
  34.     Preferences_Resource flag(labelup) iconUpLabel {$flist(newMsgs) Unseen}
  35.     Preferences_Resource flag(labeldown) iconDownLabel exmh
  36.     Preferences_Resource flag(labelspool) iconSpoolLabel {$exmh(numUnInced) Spooled}
  37.     Preferences_Resource flag(iconupmask) iconUpMask flagup.mask
  38.     Preferences_Resource flag(icondownmask) iconDownMask flagdown.mask
  39.     Preferences_Resource flag(iconspoolmask) iconSpoolMask flagspool.mask
  40.     Preferences_Resource flag(iconupglyph) iconUpGlyph flagup.gif
  41.     Preferences_Resource flag(icondownglyph) iconDownGlyph flagdown.gif
  42.     Preferences_Resource flag(iconspoolglyph) iconSpoolGlyph flagspool.gif
  43.  
  44.     foreach i {iconup icondown iconspool iconupmask icondownmask iconspoolmask iconupglyph icondownglyph iconspoolglyph} {
  45.     if ![string match /* $flag($i)] {
  46.         set flag($i) $exmh(library)/$flag($i)
  47.     }
  48.     if ![file exists $flag($i)] {
  49.         set flag($i) 0
  50.     }
  51.     }
  52.     if {$exmh(slowDispColorIcon)} {
  53.     if [catch {
  54.         Exmh_Debug "Creating .icon"
  55.         toplevel .icon
  56.         wm group .icon .
  57.         pack [canvas .icon.c]
  58.         image create photo icondown -file $flag(icondownglyph)
  59.         image create photo iconup -file $flag(iconupglyph)
  60.         image create photo iconspool -file $flag(iconspoolglyph)
  61.         .icon.c configure -width [image width iconup] \
  62.             -height [image height iconup]
  63.         wm iconwindow . .icon
  64.     } err] {
  65.         Exmh_Debug "Can't create .icon: $err"
  66.         destroy .icon
  67.     }
  68.     }
  69.     FlagInner down icondown labeldown
  70. }
  71. proc Flag_NewMail { {folder {}} } {
  72.     FlagInner up iconup labelup
  73. }
  74. # Flag_MsgSeen drops the flag but retains the proper label
  75. # This is called after viewing a message
  76. proc Flag_MsgSeen { {folder {}} } {
  77.     global flist
  78.     if {$flist(newMsgs) > 0} {
  79.     FlagInner spool iconspool labelup
  80.     } else {
  81.     FlagInner down icondown labeldown
  82.     }
  83. }
  84. proc Flag_NoUnseen {} {
  85.     FlagInner down icondown labeldown
  86. }
  87. proc Flag_Spooled {} {
  88.     FlagInner spool iconspool labelspool
  89. }
  90. proc Flag_NoSpooled {} {
  91.     FlagInner down icondown labeldown
  92. }
  93. proc FlagInner {state icon label} {
  94.     global exmh flag
  95.     Exmh_Debug "In FlagInner $state $icon $label"
  96.     if {$flag(state) != $state} {
  97.     if [winfo exists .icon.c] {
  98.         Exmh_Debug "Setting flag glyph to $icon"
  99.         .icon.c delete image -tag icon
  100.         .icon.c create image 0 0 -anchor nw -image $icon -tag icon
  101.     } else {
  102.         Exmh_Debug "Setting flag bitmap to $icon"
  103.         wm iconbitmap . @$flag($icon)
  104.         if {$flag(${icon}mask) != 0} {
  105.         wm iconmask . @$flag(${icon}mask)
  106.         }
  107.     }
  108.     set flag(state) $state
  109.     Exmh_Debug "Set flag state to $state"
  110.     }
  111.     set l [uplevel #0 list $flag($label)]
  112.     if {[info exists flag(lastLabel)] &&
  113.     ([string compare $l $flag(lastLabel)] == 0)} {
  114.     return
  115.     }
  116.     wm title . $l
  117.     wm iconname . $l
  118.     set flag(lastLabel) $l
  119.  
  120. }
  121.